package com.bangdao.service.edu.controller;

import com.bangdao.result.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author CHENHAI
 * @create 2020-11-05 23:24
 */

/**
 * 提供前端交互接口
 */
@Api(tags = "登录接口")
@RestController
@RequestMapping("/user")
public class LoginController {


    /**
     * 登录
     *
     * @return
     */
    @ApiOperation("登录")
    @PostMapping("login")
    public R login() {
        return R.ok().data("token", "admin");
    }

    /**
     * 获取用户信息
     *
     * @return
     */
    @ApiOperation("获取用户信息")
    @GetMapping("info")
    public R info() {
        return R.ok()
                .data("roles", "[admin]")
                .data("name", "admin")
                .data("avatar", "https://oss.aliyuncs.com/aliyun_id_photo_bucket/default_handsome.jpg");
    }

    /**
     * 退出
     *
     * @return
     */
    @ApiOperation("退出")
    @PostMapping("logout")
    public R logout() {
        return R.ok();
    }
}

